package com.oco.restcontroller.api.feignclient.userinfo.web;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.oco.restcontroller.api.feignclient.userinfo.client.points.IPointsClient;
import com.oco.restcontroller.api.resttemplate.common.ResultMap;

/**
 * 用户信息RESTFul接口
 * @author zhangzhihong
 * @email it_javasun@yeah.net
 * @since 2016年8月10日上午9:39:56
 */
@RestController
@RequestMapping(value="${spring.web.apiversion}/feignclient/userinfo")
public class RestFeignclientUserIfoController {

	private static final Logger logger = LoggerFactory.getLogger(RestFeignclientUserIfoController.class);
	
	@Resource(name = "HystrixPointsClient")
	private IPointsClient pointAccountClient;
	
	@RequestMapping(value="/getRemoteService", method = RequestMethod.POST, headers = "Accept=application/json")
	public @ResponseBody ResponseEntity<String> getRemoteService(@RequestBody Map<String, Object> paramMap) throws Exception {
		HttpHeaders headers = new HttpHeaders();
		Map<String, Object> result = new HashMap<String, Object>();
		headers.add("Content-Type", MediaType.APPLICATION_JSON_UTF8.toString());
		String json = ResultMap.objectMapper().writeValueAsString(paramMap);
		result = pointAccountClient.queryRedeemSearch(json);
		return new ResponseEntity<String>(new ObjectMapper().writeValueAsString(result), headers, HttpStatus.OK);
	}
}
